package com.dailyblue.project.estate.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @Auther:Liu
 * @Testname:AiController
 * @Date:2025/9/22 10:34
 */
@RestController
@RequestMapping("/ai")
public class AiController {
    @Resource
    private ChatClient ollamaClient;

    @GetMapping("/call")
    String call(@RequestParam("message") String message) {
        return ollamaClient.prompt().user(message).call().content();
    }


    @GetMapping(value = "/stream",produces = "text/html;charset=utf-8")
    Flux<String> stream(@RequestParam("message")String message) {
        return ollamaClient.prompt().user(message).stream().content();
    }


}
